package cn.ehanghai.iot.common.controller;


import cn.ehanghai.iot.common.security.constants.Constants;
import cn.ehanghai.iot.common.security.constants.ReturnCode;

public class BaseController {


    public ReturnCode errorException(Integer code, String reason) {
        ReturnCode returnCode = Constants.getReturnCode(code);
        returnCode.setReason(reason);
        return returnCode;
    }

    public ReturnCode errorException(Integer code) {
        ReturnCode returnCode = Constants.getReturnCode(code);
        return returnCode;
    }

    public ReturnCode success(Object object) {
        ReturnCode returnCode = Constants.getReturnCode(Constants.ERROR_CODE_NONE);
        returnCode.setResult(object);
        return returnCode;
    }

    public ReturnCode success() {
        return success(null);
    }

    public ReturnCode success(Object object, String token) {
        ReturnCode returnCode = Constants.getReturnCode(Constants.ERROR_CODE_NONE);
        returnCode.setResult(object);
        returnCode.setToken(token);
        return returnCode;
    }

}
